import React from 'react';
import { getAccAmoebaChanceAffirm } from '../../../../financialApi'
import { Modal, Form, Input, message } from 'antd';
const { TextArea } = Input;

const NoStateModule = ({ okAndNoStateModuleShow, setOkAndNoStateModuleShow, clickId, handleSelectModuleOk }) => {
    const [form] = Form.useForm();
    const { validateFields, resetFields } = form;
    const handleOk = () => {
        validateFields().then(values => {
            const parames = {
                id: clickId,
                isReceive: false,
                ...values
            }
                ; (async () => {
                    const { code, msg } = await getAccAmoebaChanceAffirm(parames);
                    if (code === '20000') {
                        message.success('驳回成功！');
                        resetFields();
                        handleSelectModuleOk();
                    } else {
                        message.error(msg);
                    }
                })()
            setOkAndNoStateModuleShow(false);
        })

    };

    const handleCancel = () => {
        resetFields();
        setOkAndNoStateModuleShow(false);
    };
    return <Modal title="驳回" visible={okAndNoStateModuleShow} onOk={handleOk} onCancel={handleCancel}>
        <Form form={form} >
            <Form.Item
                label="驳回原因"
                name="why"
                rules={[{ required: true, message: '请输入驳回原因!' }]}
                labelCol={{ span: 24, offset: 0 }}
            >
                <TextArea showCount maxLength={100} />
            </Form.Item>
        </Form>
    </Modal>
}

export default NoStateModule;